<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>View Discount | Merlion's ERP System</title>
    </ui:define>
    
    <ui:define name="content">
        <p:panel id="panel" header="View Discounts">
         <p:tabView style="display: inline-block; width: 99%;">
            <p:tab title="Nuts">
                <h:form prependId="false">
            
                    <p:dataTable var="discount" value="#{viewDiscountManagerBean.productPriceA}" 
                                 dynamic="true" paginator="true" rows="5" emptyMessage="No discount found in database." selection="#{viewDiscountManagerBean.selectedDiscount}">             
                            <p:column selectionMode="single" />

                            <p:column id="discountId" sortBy="#{discount.discountId}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="ID" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountId}" /> 
                            </p:column> 

                            <p:column id="productType" sortBy="#{discount.productType}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Product Type" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.productType}" /> 
                            </p:column> 

                            <p:column sortBy="#{discount.lowerLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Lower Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.lowerLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.higherLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Upper Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.higherLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.discountRate}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Discount Rate" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountRate}" /> 
                            </p:column>
                
                            <f:facet name="footer">  
                                <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{viewDiscountManagerBean.editDiscount}"/>                             
                                <p:commandButton value="Delete" image="ui-icon ui-icon-trash" update="display3 display4" onclick="discountDeleteDialog1.show()">
                                    <f:setPropertyActionListener value="#{discount}" target="#{viewDiscountManagerBean.selectedDiscount}"/>
                                </p:commandButton>
                            </f:facet>
                    </p:dataTable>

                    <p:confirmDialog widgetVar="discountDeleteDialog1" message="Are you sure to delete the discount?"  
                showEffect="clip" hideEffect="fold" 
                header="Initiating delete process" severity="alert">  

                        <p:commandButton value="Yes" update="messages" oncomplete= "discountDeleteDialog1.hide()"  
                                         actionListener="#{viewDiscountManagerBean.deleteDiscount(event)}" />  
                        <p:commandButton value="No" onclick="discountDeleteDialog1.hide()" type="button" />  
                    </p:confirmDialog>
                </h:form>
            </p:tab>
             
             <p:tab title="Fruits">
                <h:form>
            
                    <p:dataTable var="discount" value="#{viewDiscountManagerBean.productPriceB}" 
                                 dynamic="true" paginator="true" rows="5" emptyMessage="No discount found in database." selection="#{viewDiscountManagerBean.selectedDiscount}">             
                            <p:column selectionMode="single" />

                            <p:column id="discountId" sortBy="#{discount.discountId}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="ID" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountId}" /> 
                            </p:column> 

                            <p:column id="productType" sortBy="#{discount.productType}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Product Type" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.productType}" /> 
                            </p:column> 

                            <p:column sortBy="#{discount.lowerLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Lower Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.lowerLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.higherLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Upper Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.higherLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.discountRate}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Discount Rate" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountRate}" /> 
                            </p:column>
                
                            <f:facet name="footer">  
                                <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{viewDiscountManagerBean.editDiscount}"/>                             
                                <p:commandButton value="Delete" image="ui-icon ui-icon-trash" update="display3 display4" onclick="discountDeleteDialog2.show()">
                                    <f:setPropertyActionListener value="#{discount}" target="#{viewDiscountManagerBean.selectedDiscount}"/>
                                </p:commandButton>
                            </f:facet>
                    </p:dataTable>

                    <p:confirmDialog message="Are you sure to delete the discount?"  
                showEffect="clip" hideEffect="fold" 
                header="Initiating delete process" severity="alert" widgetVar="discountDeleteDialog2">  

                        <p:commandButton value="Yes" update="messages" oncomplete= "discountDeleteDialog.hide()"  
                                         actionListener="#{viewDiscountManagerBean.deleteDiscount}" />  
                        <p:commandButton value="No" onclick="discountDeleteDialog2.hide()" type="button" />  
                    </p:confirmDialog>
                </h:form>
            </p:tab>
             
             <p:tab title="Chocolate Nuts">
                <h:form>
            
                    <p:dataTable var="discount" value="#{viewDiscountManagerBean.productPriceC}" 
                                 dynamic="true" paginator="true" rows="5" emptyMessage="No discount found in database." selection="#{viewDiscountManagerBean.selectedDiscount}">             
                            <p:column selectionMode="single" />

                            <p:column id="discountId" sortBy="#{discount.discountId}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="ID" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountId}" /> 
                            </p:column> 

                            <p:column id="productType" sortBy="#{discount.productType}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Product Type" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.productType}" /> 
                            </p:column> 

                            <p:column sortBy="#{discount.lowerLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Lower Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.lowerLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.higherLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Upper Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.higherLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.discountRate}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Discount Rate" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountRate}" /> 
                            </p:column>
                
                            <f:facet name="footer">  
                                <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{viewDiscountManagerBean.editDiscount}"/>                             
                                <p:commandButton value="Delete" image="ui-icon ui-icon-trash" update="display3 display4" onclick="discountDeleteDialog3.show()">
                                    <f:setPropertyActionListener value="#{discount}" target="#{viewDiscountManagerBean.selectedDiscount}"/>
                                </p:commandButton>
                            </f:facet>
                    </p:dataTable>

                    <p:confirmDialog message="Are you sure to delete the discount?"  
                showEffect="clip" hideEffect="fold" 
                header="Initiating delete process" severity="alert" widgetVar="discountDeleteDialog3">  

                        <p:commandButton value="Yes" update="messages" oncomplete= "discountDeleteDialog.hide()"  
                                         actionListener="#{viewDiscountManagerBean.deleteDiscount}" />  
                        <p:commandButton value="No" onclick="discountDeleteDialog3.hide()" type="button" />  
                    </p:confirmDialog>
                </h:form>
            </p:tab>
             
             <p:tab title="Redcurrant Fruits">
                <h:form>
            
                    <p:dataTable var="discount" value="#{viewDiscountManagerBean.productPriceD}" 
                                 dynamic="true" paginator="true" rows="5" emptyMessage="No discount found in database." selection="#{viewDiscountManagerBean.selectedDiscount}">             
                            <p:column selectionMode="single" />

                            <p:column id="discountId" sortBy="#{discount.discountId}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="ID" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountId}" /> 
                            </p:column> 

                            <p:column id="productType" sortBy="#{discount.productType}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Product Type" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.productType}" /> 
                            </p:column> 

                            <p:column sortBy="#{discount.lowerLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Lower Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.lowerLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.higherLimit}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Upper Limit" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.higherLimit}" /> 
                            </p:column>

                            <p:column sortBy="#{discount.discountRate}"> 
                                <f:facet name="header"> 
                                    <h:outputText value="Discount Rate" /> 
                                </f:facet> 
                                <h:outputText value="#{discount.discountRate}" /> 
                            </p:column>
                
                            <f:facet name="footer">  
                                <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{viewDiscountManagerBean.editDiscount}"/>                             
                                <p:commandButton value="Delete" image="ui-icon ui-icon-trash" update="display3 display4" onclick="discountDeleteDialog4.show()">
                                    <f:setPropertyActionListener value="#{discount}" target="#{viewDiscountManagerBean.selectedDiscount}"/>
                                </p:commandButton>
                            </f:facet>
                    </p:dataTable>

                    <p:confirmDialog message="Are you sure to delete the discount?"  
                showEffect="clip" hideEffect="fold" 
                header="Initiating delete process" severity="alert" widgetVar="discountDeleteDialog4">  

                        <p:commandButton value="Yes" update="messages" oncomplete= "discountDeleteDialog.hide()"  
                                         actionListener="#{viewDiscountManagerBean.deleteDiscount}" />  
                        <p:commandButton value="No" onclick="discountDeleteDialog4.hide()" type="button" />  
                    </p:confirmDialog>
                </h:form>
            </p:tab>
         </p:tabView>
        </p:panel>
    </ui:define>

</ui:composition>

